// 1.设置
export const setItem = (key, val) => {
  if (typeof val === "object") {
    val = JSON.stringify(val);
  }
  localStorage.setItem(key, val);
};
// 2.获取
export const getItem = (key) => {
  let val = localStorage.getItem(key);
  try {
    return JSON.parse(val);
  } catch (err) {
    return val;
  }
};
// 3.删除;
export const removeItem = (key) => {
  localStorage.removeItem(key);
};
